
Polygon P;
P.push_back (Point (0, 0));
P.push_back (Point (500, 0));
P.push_back (Point (350, 150));
P.push_back (Point (250, 50));
P.push_back (Point (150, 150));
std::cout << "P = ";

Polygon Q;

Q.push_back (Point (50, 20));
Q.push_back (Point (350, 50));
Q.push_back (Point (250, 150));
Q.push_back (Point (150, 50));
Q.push_back (Point (0, 200));
// Compute the intersection of P and Q.
std::list<Polygon_wh>                  intR;
std::list<Polygon_wh>::const_iterator  it;

std::cout << " simple? " << P.is_simple() << std::endl;
std::cout << " is_convex? " << P.is_convex() << std::endl;
std::cout << " bbox? " << P.bbox() << std::endl;
std::cout << " area? " << P.area() << std::endl;
std::cout << " size " << P.size() << std::endl;


std::cout << " simple? " << Q.is_simple() << std::endl;
std::cout << " is_convex? " << Q.is_convex() << std::endl;
std::cout << " bbox? " << Q.bbox() << std::endl;
std::cout << " area? " << Q.area() << std::endl;
std::cout << " size " << Q.size() << std::endl;

CGAL::intersection (P, Q, std::back_inserter(intR));

std::cout << "The intersection:" << std::endl;
for (it = intR.begin(); it != intR.end(); ++it) {
  std::cout << "--> ";
}    

pgi = new CGAL::Qt::PolygonGraphicsItem<Polygon>(&P);
pgi->setVerticesPen(QPen(Qt::yellow, 5, Qt::SolidLine, 
    Qt::RoundCap, Qt::RoundJoin));
pgi->setEdgesPen(QPen(Qt::black, 3, Qt::SolidLine, Qt::RoundCap, 
    Qt::RoundJoin));
scene.addItem(pgi);

pgi = new CGAL::Qt::PolygonGraphicsItem<Polygon>(&Q);
 pgi->setVerticesPen(QPen(Qt::blue, 5, Qt::SolidLine, 
     Qt::RoundCap, Qt::RoundJoin));
 pgi->setEdgesPen(QPen(Qt::yellow, 3, Qt::SolidLine, Qt::RoundCap, 
     Qt::RoundJoin));
 scene.addItem(pgi);

std::cout << " poly line intersection" << intR.size() << std::endl;
for ( i = intR.begin(); i != intR.end(); i++ ) {
    std::cout << " number of holes " 
        << i->number_of_holes() 
        << std::endl;
    CGAL::Qt::PolygonWithHolesGraphicsItem<Polygon_wh> * minkgi;
    minkgi = new CGAL::Qt::PolygonWithHolesGraphicsItem<Polygon_wh>(&(*i));
    minkgi->setVerticesPen(QPen(Qt::red, 10, Qt::SolidLine, Qt::RoundCap, 
        Qt::RoundJoin));
    scene.addItem(minkgi);
    minkgi->setEdgesPen(QPen(Qt::red, 2, Qt::SolidLine, Qt::RoundCap, 
        Qt::RoundJoin));

    Polygon outer_boundary = i->outer_boundary();
    for( int i = 0; i < outer_boundary.size() ; i++ ) {
        cout << outer_boundary[i] << endl;
    }
}

//
//Point linePoints3[] = { Point(0,-200), Point(200,200),Point(250,200)};
//Polygon polyLine3(linePoints3,linePoints3+3);
//pgi = new CGAL::Qt::PolygonGraphicsItem<Polygon>(&polyLine3);
//pgi->setVerticesPen(QPen(Qt::yellow, 5, Qt::SolidLine, 
//    Qt::RoundCap, Qt::RoundJoin));
//pgi->setEdgesPen(QPen(Qt::black, 3, Qt::SolidLine, Qt::RoundCap, 
//    Qt::RoundJoin));
//scene.addItem(pgi);
//
//std::list< Polygon_wh > intR2;
//
//CGAL::intersection( pgn, polyLine3,  std::back_inserter(intR2));
//
//std::cout << " poly line intersection" << intR2.size() << std::endl;
//for ( i = intR2.begin(); i != intR2.end(); i++ ) {
//    std::cout << " number of holes " 
//        << i->number_of_holes() 
//        << std::endl;
//    CGAL::Qt::PolygonWithHolesGraphicsItem<Polygon_wh> * minkgi;
//    minkgi = new CGAL::Qt::PolygonWithHolesGraphicsItem<Polygon_wh>(&(*i));
//    minkgi->setVerticesPen(QPen(Qt::black, 10, Qt::SolidLine, Qt::RoundCap, 
//        Qt::RoundJoin));
//    scene.addItem(minkgi);
//    minkgi->setEdgesPen(QPen(Qt::blue, 2, Qt::SolidLine, Qt::RoundCap, 
//        Qt::RoundJoin));
//    
//    Polygon outer_boundary = i->outer_boundary();
//    for( int i = 0; i < outer_boundary.size() ; i++ ) {
//        cout << outer_boundary[i] << endl;
//    }
//}